// components/publish_menu/publish_menu.js
let app = getApp();
Component({
  properties: {
    isshow: { // 属性名
      type: Boolean, // 类型（必填），目前接受的类型包括：String, Number, Boolean, Object, Array, null（表示任意类型）
      value: '', // 属性初始值（可选），如果未指定则会根据类型选择一个
      observer(newVal, oldVal, changedPath) {

        let animate = wx.createAnimation({
          timingFunction: 'ease-in',
          duration: 200
        })
        if (newVal) {
          // 打开
          this.setData({ show: true });
          setTimeout(() => {
            animate.opacity(1).translateY(0).step();
            this.setData({
              animate: animate.export()
            })
          }, 80);



        } else {
          // 关闭
          animate.opacity(0).translateY(30).step();
          this.setData({
            animate: animate.export()
          })
          setTimeout(() => {
            this.setData({ show: false });
          }, 200);
        }
      }
    },
  },
  data: {
    show: false,
    animate:''
  },
  methods: {
    close() {
      this.triggerEvent('close', {}, {})
    },
    publish(e){
      let type = e.currentTarget.dataset.type;
      console.log(type)
      if(!app.common.token){
        app.toast("请先登陆");
        return;
      }

      if (app.common.user_info.auth_status == 1) {
        app.toast("请先认证");
        setTimeout(() => {
          wx.navigateTo({
            url: '/pages/user/renzheng/renzheng'
          })
        }, 600);
        this.close();
        return
      } else if (app.common.user_info.auth_status == 2) {
        app.toast("认证资料审核中");
        this.close();
        return
      } else if (app.common.user_info.auth_status == 3) {
        // app.toast("认证资料审核通过");
        if(app.common.user_info.role==1){
          app.toast("无发布权限");
          this.close();
          return
        }
      } else if (app.common.user_info.auth_status == 4) {
        app.toast("认证未通过");
        this.close();
        return
      }

      if(type=="quanzhi"){
         
        this.close();
				wx.navigateTo({
				  url:'/pages/all_time/quanzhifabu/release'
				})
      }
      if(type=="jianzhi"){
        this.close();
        wx.navigateTo({
          url:'/pages/part_time/release/release'
        })
      }

    }
  }
})
